package com.collection;

import java.util.ArrayList;
import java.util.List;

public class ExtendsCollectionDemo {
    class Apple {}
    class Fruit extends Apple {}
    class VeryFruit extends Fruit {}

    class Pear extends Apple {}

    class VeryPear extends Apple {}

    public void test(){
        List<Apple> apples = new ArrayList<>();
        apples.add(new Apple());
        apples.add(new Fruit());
        apples.add(new VeryFruit());
        apples.add(new Pear());
        apples.add(new VeryPear());
        for (Apple apple : apples) {
            System.out.println(apple);
        }
    }
}
